package com.example.goods_service.controller;

import com.example.goods_service.return_data.Mall_Data;
import com.example.goods_service.service.rpc.User_servcie;
import com.example.goods_service.vo.SearchRecords;
import com.example.goods_service.vo.T_commodity;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
public class Gfc_contorller {
    @Autowired
    GoodsController_liujingxi goodsController_liujingxi;
    @Autowired
    GoodsController_oyhl goodsController_oyhl;
    @Autowired
    Mall_Data mall_data;
    @Autowired
    User_servcie user_servcie;

    @ApiOperation("猜你喜欢")
    @RequestMapping("/g_cnxh")
    public Mall_Data g_cnxh(@RequestParam(required = false) Integer userid) {
        List<Integer> goodsid_s = new ArrayList<>();
        Map<Integer, Integer> goodstype_s = new HashMap<Integer, Integer>();
        Mall_Data mall_data = user_servcie.select_my_tracks(userid);
        Object data = mall_data.get("data");
        System.out.println(data);

        //goondsid查询商品类型
        goodsid_s.forEach(s -> {
            List<T_commodity> selectgoods = (List<T_commodity>) goodsController_liujingxi.selectgoods(s);
            if (goodstype_s.get(selectgoods.get(0).getCategory_id()) != null) {
                int categroy_id = goodstype_s.get(selectgoods.get(0).getCategory_id());
                goodstype_s.put(selectgoods.get(0).getCategory_id(), categroy_id + 1);
            } else {
                //没有就存入
                goodstype_s.put(selectgoods.get(0).getCategory_id(), 1);
            }
        });


        return null;
    }
}
